package com.nowc.month.m120;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
import java.util.stream.Collectors;

public class a {

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws IOException {
        int T = Integer.parseInt(br.readLine());
        while (T-- > 0) {
            solve();
        }
        out.flush();
        out.close();
        br.close();
    }

    static void solve() throws IOException {
         int n = Integer.parseInt(br.readLine());
         char[] s = br.readLine().toCharArray();
         Map<Character, Integer> map = new HashMap<Character, Integer>();
         for (int i = 0; i < n; i++) {
             map.put(s[i], map.getOrDefault(s[i], 0) + 1);
         }
         map = map.entrySet().stream()
                 .sorted(Map.Entry.comparingByValue())
                 .collect(Collectors.toMap(
                         Map.Entry::getKey,
                         Map.Entry::getValue,
                         (e1, e2) -> e1,
                         LinkedHashMap::new
                 ));
         int pre = -1;
         for (Map.Entry<Character, Integer> entry : map.entrySet()) {
             if (pre != -1) {
                 if (entry.getValue() != pre + 1) {
                     out.println("NO");
                     return;
                 }
             }
             pre = entry.getValue();
         }
         out.println("YES");
    }
}
